#ifndef __STDMYSTRING_H_
#define __STDMYSTRING_H_

#include <iostream>

class MyStringList; // 前置声明
// 字符串
class StdMyString
{
public:
    StdMyString();
    StdMyString(const char *str);
    StdMyString(const StdMyString &str);
    ~StdMyString();
    const char *c_str()
    {
        return string;
    }

    StdMyString& operator=(const StdMyString& str);
    StdMyString operator+=(const StdMyString &str);
    StdMyString& operator+=(const char &c);
    StdMyString operator+(const StdMyString& str);

    StdMyString& operator-=(const StdMyString& str);
    StdMyString operator-(const StdMyString& str);

    char &operator[](int index);

    // 逻辑运算符重载
    bool operator == (const StdMyString &str);
    bool operator > (const StdMyString &str);
    bool operator < (const StdMyString &str);
    // bool operator&&(const StdMyString &str);

    friend std::ostream& operator<<(std::ostream &os, const StdMyString &str);
    friend std::istream& operator>>(std::istream& is, StdMyString& str);

    operator int();
    operator double();

    // 字符串切割函数
    MyStringList split(const StdMyString& str);


private:
    char *string;
    int size;
    int capacity;

};

std::ostream& operator<<(std::ostream &os, const StdMyString &str);
std::istream& operator>>(std::istream& is, StdMyString& str);


// 字符串数组
class MyStringList
{
public:
    MyStringList(int capacity = 15);
    ~MyStringList();
    // 拷贝构造 赋值运算符重载
    // - -= == > < [] >>

    MyStringList& operator+=(const StdMyString &str);

    MyStringList& operator<<(const StdMyString& str);

    MyStringList operator+(const MyStringList &list);

    StdMyString &operator[](int index)
    {
        return array[index];
    }

    friend std::ostream& operator<<(std::ostream& os, const MyStringList& list);

private:
    StdMyString *array;
    int size;
    int capacity;
};

std::ostream& operator<<(std::ostream& os, const MyStringList& list);

#endif